<?php
$next_start_date = strtotime('next ' . $weeks[ $session->publication->publication_day - 1] );
?>

<td class="align-top">
    
<table class="inset-table">
    <thead>
        <tr class="heading-row skin-gradient">
           <th>Add New Subscription:</th>
        </tr>
    </thead>
    <tbody>
        <form action="<?php echo $Controller->page_url(); ?>" method="post">
        <tr>
            <td id="add-time">
                
               <div class="shaded padded">
               <strong>Set Start Date:</strong><br><br>
               <label><span>Set Start date: (<?php echo $weeks[ $session->publication->publication_day ]; ?>) </span>
                   
               <input class="datepicker" type="text" value="<?php echo date('Y-m-d', $next_start_date) ; ?>" name="start_date" readonly />
               </label>
               </div>
               
               <hr>
                <table class="inset-table">

                    <tr>
                        <td width="45%" class="shaded">
                            <strong>Set End Date:</strong><br><br>
                           <label><span>Set End Date:  (<?php echo $weeks[ $session->publication->publication_day ]; ?>) </span>
                            <input class="datepicker" type="text" value="" name="end_date" readonly />
                           </label>
                        </td>
                        
                        <td class="text-centered" width="10%">
                            <strong>OR</strong>
                        </td>
                        <td width="45%" class="shaded">
                            <strong>Set Total Amount:</strong><br><br>
                            <label>
                            <input type="radio" name="total_duration" value="156" /><span>3 Years</span>
                            </label>
                            
                            <label>
                            <input type="radio" name="total_duration" value="104" /><span>2 Years</span>
                            </label>
                            
                            <label>
                            <input type="radio" name="total_duration" value="52" /><span>1 Year</span>
                            </label>
                            
                            <label>
                            <input type="radio" name="total_duration" value="0" /><span>Other</span>
                            <input type="number" name="total_duration_other" placeholder="Weeks" />
                                <span class="show-tool-tip" title="The duration, in weeks.">?</span>
                            </label>
                        </td>
                    </tr>
                </table>

                
            </td>
        </tr>
        <tr>
            <td class="group">

                <input class="right" type="hidden" name="type" value="add"/>
                <input class="right" type="hidden" name="publication_id" value="<?php echo $session->publication->publication_id; ?>"/>
                <input class="right" type="hidden" name="user_id" value="<?php $user->attr('user_id'); ?>"/>
                <input class="right" type="hidden" name="action" value="update_subscription"/>
                <input class="primary-button skin-gradient right" type="submit" name="update_subscription" value="Add"/>
                <a class="show-tool-tip right text-button" href="#" title="Here you can add a new subscription to a user, and give it some starting allowance. <br><em>Please note: You cannot have two simultaneous subscriptions, and you must schedule a subscription to begin now, or in the future.</em>">Help</a>

            </td>
        </tr>
        </form>
    </tbody>
</table>

<div id="subscription-buttons" class="group button-group padding margin-top">
<a class="grey button left" href="<?php echo $Controller->page_url('subscriptions'); ?>">&laquo; Back to Subscriptions</a>
<a class="grey button left" href="<?php echo $Controller->page_url('edit'); ?>">Add another Subscription &raquo;</a>
</div>

</td>